﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using CrushersCode;

namespace BFF_EnrollmentSystem
{
    public partial class LoginForm : Form
    {
        ParentForm parent;
        DatabaseConnection dbc = new DatabaseConnection();

        public LoginForm(ParentForm p)
        {
            parent = p;
            InitializeComponent();
            button1.Click += new EventHandler(button1_Click);
        }

        void button1_Click(object sender, EventArgs e)
        {
            dbc.dbconnection();
            dbc.mylogin("SELECT * from tbluser WHERE Username = '" + txtUser.Text + "' and Password = '" + this.txtPass.Text + "'");
            if (dbc.tbl.Rows.Count > 0)
            {
                MessageBox.Show("Login Successful", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                this.Close();
            }
            else
            {
                MessageBox.Show("Invalid Username or Password");
                txtUser.Text = "";
                txtPass.Text = "";
                txtUser.Focus();

            }
            dbc.DBClose();
        }
    }
}
